package xj.util.gui;

import java.awt.geom.Point2D;
import java.io.Serializable;

/**
 * Adapt from java.awt.geom.Point2D.Float to make it serializable.
 * 
 * The <code>Point2DFloat</code> class defines a point specified in float
 * precision.
 */
public class Point2DFloat extends Point2D implements Serializable {
  /**
   * The X coordinate of this <code>Point2D</code>.
   * 
   * @since JDK1.2
   */
  public float x;

  /**
   * The Y coordinate of this <code>Point2D</code>.
   * 
   * @since JDK1.2
   */
  public float y;

  /**
   * Constructs and initializes a <code>Point2D</code> with coordinates
   * (0,&nbsp;0).
   * 
   * @since JDK1.2
   */
  public Point2DFloat() {
  }

  /**
   * Constructs and initializes a <code>Point2D</code> with the
   * specified coordinates.
   * 
   * @param x,&nbsp;y
   *                the coordinates to which to set the newly constructed
   *                <code>Point2D</code>
   * @since JDK1.2
   */
  public Point2DFloat(float x, float y) {
    this.x = x;
    this.y = y;
  }

  /**
   * Returns the X coordinate of this <code>Point2D</code> in
   * <code>double</code> precision.
   * 
   * @return the X coordinate of this <code>Point2D</code>.
   * @since JDK1.2
   */
  @Override
  public double getX() {
    return x;
  }

  /**
   * Returns the Y coordinate of this <code>Point2D</code> in
   * <code>double</code> precision.
   * 
   * @return the Y coordinate of this <code>Point2D</code>.
   * @since JDK1.2
   */
  @Override
  public double getY() {
    return y;
  }

  /**
   * Sets the location of this <code>Point2D</code> to the specified
   * <code>double</code> coordinates.
   * 
   * @param x,&nbsp;y
   *                the coordinates to which to set this
   *                <code>Point2D</code>
   * @since JDK1.2
   */
  @Override
  public void setLocation(double x, double y) {
    this.x = (float) x;
    this.y = (float) y;
  }

  /**
   * Sets the location of this <code>Point2D</code> to the specified
   * <code>float</code> coordinates.
   * 
   * @param x,&nbsp;y
   *                the coordinates to which to set this
   *                <code>Point2D</code>
   * @since JDK1.2
   */
  public void setLocation(float x, float y) {
    this.x = x;
    this.y = y;
  }

  /**
   * Returns a <code>String</code> that represents the value of this
   * <code>Point2D</code>.
   * 
   * @return a string representation of this <code>Point2D</code>.
   * @since JDK1.2
   */
  @Override
  public String toString() {
    return "[" + x + "," + y + "]";
  }
}
